const {
  $util,
} = getApp();
Page({
  data: {
    page: 1,
    isloadmore: true,
  },
  onLoad(ops) {
    this.setData(ops);
    this.loadList();
  },
  loadList() {
    let {
      id,
      page,
    } = this.data;
    $util.request({
      url: 'entry/wxapp/partywork.appraisal.showresult',
      data: { taskid: id, page },
      showLoading: false,
      success: (res) => {
        let list = res.blist;
        if (page > 1) {
          list = [...this.data.list, ...list];
        }
        this.setData({
          list,
          hlist: res.hlist,
          isloadmore: res.blist.length > 0 ? true : false,
          page: res.blist.length > 0 ? page + 1 : page,
          isLoad: true,
        });
      },
    });
  },
  deleteDeclare(e) {
    let {
      id,
      idx,
    } = e.currentTarget.dataset;
    wx.showModal({
      title: '提示',
      content: '确定要删除该申报吗？',
      success: (res) => {
        if (res.confirm) {
          $util.request({
            url: 'entry/wxapp/partywork.appraisal.deletedeclare',
            data: { id: id },
            showLoading: false,
            success: () => {
              let list = this.data.list;
              list.splice(idx, 1);
              this.setData({
                list: list,
              });
            },
          });
        }
      },
    });
  },
  onReachBottom() {
    this.data.isloadmore && this.loadList();
  },
});